﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BIS.Portal.Core.Base;
using BIS.Portal.Core.Entity;
using BIS.Portal.Core.Global;

namespace BIS.Portal.Modules.CMS
{
    public partial class CmsSimpleSearchControl_Settings : ControlSettingBase
    {
        #region Load Control settings
        public string PageAlias
        {
            get { return GetControlSetting<string>(ModuleSettingNames.CmsSimpleSearch.ddlPageAlias,PortalContext.LanguageAlias); }
        }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            BindListOfPageAlias();
            ddlPageAlias.SelectedValue = PageAlias;
        }
        private void BindListOfPageAlias()
        {
            Dictionary<string, FullPageSiteEntity> listOfPage = new Dictionary<string, FullPageSiteEntity>();
            PortalContext.GetPageList(0, ref listOfPage, "", false);

            ddlPageAlias.Items.Clear();
            foreach (KeyValuePair<string, FullPageSiteEntity> page in listOfPage)
            {
                if (page.Value.PageAlias != PortalContext.PageAlias)
                {
                    ddlPageAlias.Items.Add(new ListItem(page.Key, page.Value.PageAlias));
                }
            }
        }
        public override void SaveSettings(System.Collections.Generic.Dictionary<string, string> settings)
        {
            SetControlSettingForAllLanguages(ddlPageAlias.ID, ModuleSettingNames.CmsSimpleSearch.ddlPageAlias, settings);
        }
    }
}